﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;

public class MainWindow : MonoSingleton<MainWindow> {

    SettingData _settingdata;
    public Toggle _toogle_random;
    public Toggle _toogle_camMode;
    public Button _btn_save;
    public Button _btn_cancel;

    protected override void Init()
    {
        base.Init();

        _settingdata = SettingManager.Instance._settingData;

        _toogle_random.isOn = _settingdata._effect_mode == EffectMode.Random ? true : false;
        _toogle_camMode.isOn = _settingdata._cam_mode == CameraMode.Normal ? false : true;

        _toogle_random.onValueChanged.AddListener(OnRandomToggleClick);
        _toogle_camMode.onValueChanged.AddListener(OnCameraModeToggleClick);
        _btn_save.onClick.AddListener(() => {
            SettingManager.Instance.SaveSetting();
            gameObject.SetActive(false);
        });
        _btn_cancel.onClick.AddListener(() => {
            gameObject.SetActive(false);
        });
    }

    // Update is called once per frame
    void Update () {
		
	}

    private void OnRandomToggleClick(bool value)
    {
        _settingdata._effect_mode = value ? EffectMode.Random : EffectMode.Stable;
    }

    private void OnCameraModeToggleClick(bool value)
    {
        CameraClearFlags flag = value ? CameraClearFlags.Nothing : CameraClearFlags.SolidColor;
        MainController.Instance.ChangeClearFlag(flag);
    }
}
